# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=zip-archive
pkgname=haskell-zip-archive
pkgver=0.4.3
pkgrel=17
pkgdesc="Library for creating and modifying zip archives."
url="https://github.com/jgm/zip-archive"
license=("BSD")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-digest' 'haskell-old-time' 'haskell-temporary'
         'haskell-zlib')
makedepends=('ghc' 'haskell-hunit' 'unzip')
source=("$pkgname-$pkgver.tar.gz::https://github.com/jgm/zip-archive/archive/$pkgver.tar.gz")
sha512sums=('20d2e4f179e61768fe9c5163409c75a83a6c555f2687f872ae9c44531934a8a996cfe607ff071d878abc7653abd304bac81dda033788a178efb6003448da9992')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
            -f-executable -fsplitbase
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
    cd $_hkgname-$pkgver
    runhaskell Setup test --show-details=direct
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
